<?php
// 获取待处理任务
// header("content-type:text/html;charset=utf-8");
include_once("conn.php");

if(empty($_GET['searchway'])){
    $sql = "SELECT * FROM tb_fixinfo_request, tb_fix_leave  
            WHERE tb_fixinfo_request.fix_status = '0' 
            AND tb_fixinfo_request.fix_type = tb_fix_leave.leave_name 
            ORDER BY fix_sendtime ASC";
}else{
    $pass;
}

$result = mysqli_query($conn_DB,$sql);
if ($result){
    if(mysqli_num_rows($result) <= 0){
        echo "<tr><td colspan='6'>暂无待处理任务</td></tr>";
    }else{
        while($row = mysqli_fetch_object($result)){
            if($row->leave_num == '1'){
                $fix_leave = "<button class='btn btn-danger btn-style'>一级故障</button>";
            }
            if($row->leave_num == '2'){
                $fix_leave = "<button class='btn btn-warning btn-style'>二级故障</button>";;
            }
            if($row->leave_num == '3'){
                $fix_leave = "<button class='btn btn-secondary btn-style'>三级故障</button>";;
            }
            echo"
                <tr>
                    <td>".$row->fix_name."</td>
                    <td>".$row->fix_sendtime."</td>
                    <td>".$row->fix_type."</td>
                    <td>".$fix_leave."</td>
                    <td>".$row->fix_phone."</td>
                    <td><a href='a-tasks-allocated.php?fix_id=".$row->fix_id."&action=do'>去处理</a></td>
                </tr>
            ";
        }
    }
}